home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).adf / PCQ / Runtime / writeint.asm < prev    next >
Assembly Source File  |  1989-03-31  |  801b  |  55 lines

  1.  
  2. *    WriteInt.asm (of PCQ Pascal runtime library)
  3. *    Copyright (c) 1989 Patrick Quaid
  4.  
  5. *    Write an integer to a text file.  Actually this routine, as
  6. *    written, can only be properly applied to Short values.
  7.  
  8.     SECTION    one
  9.  
  10.     XREF    outbuffer
  11.     XREF    _p%DOSBase
  12.     XREF    _LVOWrite
  13.     XREF    _p%padout
  14.  
  15.     XDEF    _p%writeint
  16. _p%writeint:
  17.  
  18.     move.l    #outbuffer+31,a0
  19.     tst.l    d0
  20.     bge.s    1$
  21.     move.w    #-1,-(sp)
  22.     neg.l    d0
  23.     bra.s    2$
  24. 1$    move.w    #1,-(sp)
  25. 2$    divu    #10,d0
  26.     move.l    d0,d1
  27.     ext.l    d0
  28.     swap    d1
  29.     add.b    #'0',d1
  30.     move.b    d1,(a0)
  31.     subq.l    #1,a0
  32.     tst.l    d0
  33.     bgt    2$
  34.     move.w    (sp)+,d0
  35.     bgt.s    3$
  36.     move.b    #'-',(a0)
  37.     subq.l    #1,a0
  38. 3$    move.l    a0,d3
  39.     sub.l    #outbuffer+31,d3
  40.     neg.l    d3
  41.     move.l    6(sp),d1
  42.     move.w    4(sp),d0
  43.     ext.l    d0
  44.     sub.l    d3,d0
  45.     ble    4$
  46.     jsr    _p%padout
  47. 4$    move.l    a0,d2
  48.     addq.l    #1,d2
  49.     move.l    _p%DOSBase,a6
  50.     jsr    _LVOWrite(a6)
  51.     rts
  52.  
  53.     END
  54.  
  55.